package com.pk.flink.partitioner;


import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.Cluster;

import java.util.Map;

public class PKPartitioner implements Partitioner {

    @Override
    public int partition(String topic, Object key, byte[] keyBytes, Object value, byte[] valueBytes, Cluster cluster) {
        String msg = new String(keyBytes);
        int partition = 0;

        if(msg.toLowerCase().contains("pk"))
        {
            partition = 0;
        }
        else if(msg.toLowerCase().contains("ruoze"))
        {
            partition = 1;
        }

        return partition;
    }

    @Override
    public void close() {

    }

    @Override
    public void configure(Map<String, ?> configs) {

    }
}
